<extend name="./public/frame.html"/>
<block name="content">
    <div class="layer_content">
        <div class="layer_form">
            <div class="down_icon"></div>
            <div class="layer_div">
                <div class="layer_tit">
                    省份：
                </div>
                <div class="layer_control">
                    <select name="province_id" id="province_id" class="w180" lay-filter="province" onclick="getProvinceList();">
                        <option value="">请选择省份</option>
                        <?php foreach($provinceList as $key=>$value):?>
                        <option value="<?php echo $value['region_id'];?>"><?php echo $value['region_name'];?></option>
                        <?php endforeach;?>
                    </select>
                </div>
            </div>
            <div class="layer_div">
                <div class="layer_tit">
                    城市：
                </div>
                <div class="layer_control">
                    <select name="city_id" id="city_id" class="w180" lay-filter="city_id">
                        <option value="">请选择城市</option>
                    </select>
                </div>
            </div>
            <div class="layer_div">
                <div class="layer_tit">
                    司机手机号：
                </div>
                <div class="layer_control">
                    <input type="text" class="w180" id="driver_phone" placeholder="司机手机号搜索">
                </div>
            </div>
            <div class="layer_div">
                <div class="layer_tit">
                    订单号：
                </div>
                <div class="layer_control">
                    <input type="text" class="w180" id="order_sn" placeholder="订单号搜索">
                </div>
            </div>
            <div class="layer_div">
                <div class="layer_tit">
                    处理结果：
                </div>
                <div class="layer_control">
                    <select id="appeal_status" class="w180">
                        <option value="">处理结果</option>
                        <option value="0">待处理</option>
                        <option value="1">申诉成功</option>
                        <option value="2">申诉失败</option>
                    </select>
                </div>
            </div>
            <div class="layer_div">
                <div class="layer_tit">
                    申诉时间：
                </div>
                <div class="layer_control">
                    <input type="text" class="w180 date" id="start" placeholder="申诉时间（开始）">
                </div>
            </div>
            <div class="layer_div">
                <div class="layer_tit">
                    申诉时间：
                </div>
                <div class="layer_control">
                    <input type="text" class="w180 date" id="end" placeholder="申诉时间（结束）">
                </div>
            </div>
            <div class="button_search">
                <button class="layui-btn" data-type="search">搜索</button>
            </div>
        </div>
    </div>
    <table class="layui-table" lay-data="{width:'auto', height:'auto', url:'{:url('DriverService/appeal')}', page:true, limit: 10, id:'appeal'}" lay-filter="appeal">
        <thead>
        <tr>
            <th lay-data="{field:'appeal_id', width:70,align:'center'}">申诉ID</th>
            <th lay-data="{field:'dressName', width:120,align:'center'}">省/市</th>
            <th lay-data="{field:'order_sn', width:180,align:'center'}">申诉订单号</th>
            <th lay-data="{field:'appeal_type',width:100,align:'center'}">申诉类型</th>
            <th lay-data="{field:'appeal_time', width:160,align:'center'}">申诉时间</th>
            <th lay-data="{field:'appeal_price', width:120,align:'center'}">申诉金额(元)</th>
            <th lay-data="{field:'appeal_status', width:120,align:'center'}">申诉结果</th>
            <th lay-data="{field:'appeal_num', width:120,align:'center'}">申诉次数</th>
            <th lay-data="{field:'driver_phone', width:120,align:'center'}">司机手机号</th>
            <th lay-data="{field:'driver_name', width:120,align:'center'}">司机姓名</th>
            <th lay-data="{field:'dispose_name', width:90,align:'center'}">处理人</th>
            <th lay-data="{field:'dispose_time', width:160,align:'center'}">处理时间</th>
            <th lay-data="{fixed:'right', toolbar: '#operate', width:100, align:'center'}">操作</th>
        </tr>
        </thead>
    </table>
    <script type="text/html" id="operate">
        <a lay-event="look">查看</a>
    </script>
    <script>
        layui.use(['table','laydate' ],function () {
            var table = layui.table, laydate = layui.laydate;
            lay('.date').each(function(){
                laydate.render({
                    elem: this
                    ,theme: '#393D49'
                    ,type: 'datetime'
                    ,trigger: 'click'
                });
            });
            var $ = layui.jquery, active = {
                search: function () {
                    var start_time 	= $('#start').val(),				//时间 - 开始
                        end_time 		= $('#end').val(),				//时间 - 结束
                        order_sn 		= $('#order_sn').val(),			//订单号
                        driver_phone 	= $('#driver_phone').val(),		//手机号 - 司机
                        province_id 	= $('#province_id').val(),		//省份
                        city_id 		= $('#city_id').val(),          //城市
                        appeal_status   = $('#appeal_status').val();    //处理结果
                    table.reload('appeal', {
                        url: '/admin/DriverService/appeal', where: {
                            "start_time" : start_time,
                            "end_time" : end_time,
                            "driver_phone" : driver_phone,
                            "order_sn":order_sn,
                            "province_id":province_id,
                            "city_id":city_id,
                            "appeal_status":appeal_status,
                        }
                    });
                }
            };
            $('.layui-btn').on('click', function () {
                var type = $(this).data('type');
                active[type] ? active[type].call(this) : '';
            });
            //监听工具条
            table.on('tool(appeal)', function (obj) {
                var data = obj.data;
                var appeal_id=data.appeal_id;
                if (obj.event === 'look') {
                    layer.open({
                        type: 2,
                        title: '异常单申诉处理',
                        shadeClose: true,
                        shade: 0.8,
                        area: ['90%', '90%'],
                        content: '{:url("/admin/DriverService/look","appeal_id=")}' + appeal_id //iframe的url
                    });
                }
            });
        });
        //选择省市切换
        function getProvinceList(){
            $("#city_id").empty();
            $("#city_id").append('<option value=>请选择城市</option>');
            var province_id = $("#province_id").val();
            $.ajax({
                url:'{:url("/admin/Franchisee/cityList")}',
                async:true,
                //dataType:'json',
                type:'post',
                data:{'province_id':province_id},
                success:function(res){
                    $("#city_id").append(res);
                },
                error:function(e){
                    layer.msg('请求错误');return false;
                }
            })
        };
    </script>
</block>
